<template>
  <div>
    <a-modal
      title="组员领取情况"
      v-model="visible"
      :footer="null"
      :width="700"
      :z-index="100"
      @cancel="onCancel"
    >
      <s-table
        bordered
        ref="table"
        size="middle"
        :row-key="(record) => record.uid"
        :custom-row="onRowClick1"
        :columns="receiveColumns"
        :data="receiveData"
      >
        <template slot="num" slot-scope="text,record">
          <a-tag color="red" @click="onNumber(record.uid)">{{text}}</a-tag>
        </template>
      </s-table>
    </a-modal>
    <m-cust v-if="receiveVisible" :receive-type="queryParam" @cancel="onCancel1"></m-cust>
  </div>
</template>

<script>
  import { STable } from '@/components'
  import leaderColumns from '@/columns/leader'
  import { receiveType } from '@/api/member'
  import MCust from '@/views/member/components/MCust'

  export default {
    props: {
      isType: {
        type: String,
        default: ''
      }
    },
    components: {
      MCust,
      STable
    },
    name: 'MReceive',
    data () {
      return {
        visible: true,
        receiveColumns: leaderColumns.lx,
        receiveData: parameters => {
          return receiveType(Object.assign(parameters, this.queryParam)).then(res => {
            this.total = res.result.total_count
            return res.result
          })
        },
        queryParam: {},
        total: 0,
        receiveVisible: false
      }
    },
    created () {
      this.queryParam['filter[type]'] = this.isType
    },
    methods: {
      onCancel () {
        this.visible = false
        this.$emit('cancel', this.visible)
      },
      onCancel1 (visible) {
        this.receiveVisible = visible
      },
      onRowClick1 (record, index) {
        return {
          on: {
            click: () => {
            },
            dblclick: () => {
              this.onCancel()
              this.$router.push({ name: 'CustomerDetail', params: { id: '40059' } })
            }
          }
        }
      },
      onNumber (id) {
        this.queryParam['filter[adviser_uid]'] = id
        this.receiveVisible = true
      }
    }
  }
</script>

<style scoped>

</style>
